package com.ykdl.app.main;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;

import com.ykdl.app.R;
import com.ykdl.app.base.BaseActivity;

public class ModifyPasswordActivity extends BaseActivity implements
		OnClickListener {

	private EditText now_pw, new_pw, repeat_pw;
	private String tNow_pw, tNew_pw, tRepeat_pw;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setTopTitle("修改密码", 0, R.drawable.back_bg, new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		}, 0, 0, null, 0);
		SetContentLayout(R.layout.activity_modify_pw);
		initView();
	}

	private void initView() {
		// TODO Auto-generated method stub
		now_pw = (EditText) findViewById(R.id.now_pw);
		new_pw = (EditText) findViewById(R.id.new_pw);
		repeat_pw = (EditText) findViewById(R.id.repeat_pw);
		findViewById(R.id.enter).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		tNow_pw = now_pw.getText().toString().trim();
		if (TextUtils.isEmpty(tNow_pw)) {
			Toast.makeText(mContext, "请输入当前密码", 0).show();
			return;
		}
		if (checkPw()) {
			upDatePW();
		} else {
			Toast.makeText(mContext, "两次新密码输入不一致", 0).show();
		}
	}
    
	/**
	 * 修改密码
	 */
	private void upDatePW() {
		// TODO Auto-generated method stub

	}

	private boolean checkPw() {
		// TODO Auto-generated method stub
		tNew_pw = new_pw.getText().toString().trim();
		tRepeat_pw = repeat_pw.getText().toString().trim();
		if (!TextUtils.isEmpty(tNew_pw) && !TextUtils.isEmpty(tRepeat_pw)
				&& tNew_pw.equals(tRepeat_pw)) {
			return true;
		}
		return false;
	}

}
